﻿using SmartCity.BasicData.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartCity.BasicData.Infrastructure.Interface
{
   public interface IBaseRepository<T> where T : BaseEntity
    {
        /// <summary>
        /// 查询全部实体表达式
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 根据id获取单个实体
        /// </summary>
        /// <param name="Id">指定的实体Id</param>
        /// <returns></returns>
        Task<T> GetModel(long Id);
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns>受影响行数</returns>
        Task<int> CreateAsync(T entity);
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns>受影响行数</returns>
        Task<int> UpdateAsync(T entity);
        /// <summary>
        /// 批量添加实体集合
        /// </summary>
        /// <param name="entities">实体集合</param>
        /// <returns>受影响行数</returns>
        Task<int> CreateRangeAsync(List<T> entities);

    }
}
